<?php


namespace App\Http\Serve;


use App\Models\User;
use Illuminate\Support\Facades\Request;

class Balance
{

    /**
     * @param $uid
     * @param $money
     * @return bool
     * @throws \Exception
     * 用户余额
     */
    public static function balance($uid,$money){
        //获取用户余额
        $balance = User::userMoney($uid);
        if($money > $balance || $balance<0){
            throw new \Exception('余额不足，请先前往个人中心进行充值');
        }
        //用户余额修改
        $remain =$balance-$money;
        User::userMoneyUpdate($uid,$remain);
        return true;
    }


}
